 
 
 **** FIGURE 2 
 
 clear
* load data
set scheme s1mono 
 import delimited  "$dir/data/raw-data/ALP_GARP_100_092418.csv", encoding(ISO-8859-1)

* add primkey
merge 1:m id using "$dir/data/raw-data/alp_stacked11.dta", keepusing(prim_key)
duplicates drop prim_key, force
rename ccei ccei100 
rename varian varian100
rename hm hm100
drop _m
merge 1:1 prim_key using "$dir/data/outputs/ALPalldatafinal.dta"
keep if _m == 3
drop _m 

egen minccei = rowmin(CCEI1 CCEI2)

gen ratio = ccei100/minccei 

keep minccei ccei100 
foreach var in  minccei ccei100  {
local i = 1
forval x = 0.7(0.05)1{
gen  `var'_`i' = `var'>=`x'
local i = `i' +1
di `x'
}
}

drop minccei ccei100
collapse minccei_* ccei100*
gen n = 1 
reshape long minccei_ ccei100_, i(n) j(bin)

replace n = 0.7 
replace n = 0.05 + n[_n-1] if _n > 1
drop bin
set scheme s1mono
la var  n "Score (is at least)"
graph bar minccei_ ccei100 , over(n) legend(order(1 "Min. CCEI" 2 "Pooled CCEI")) ytitle("Share of Subjects") yscale(r(1)) ylabel(0(0.2)1)
gr export "$dir/tables-and-figures/figure2.pdf", replace
